package com.gitee.deeround.jdbchelper;

import com.gitee.deeround.jdbchelper.core.DialectHelper;
import com.gitee.deeround.jdbchelper.out.DbType;

import java.util.concurrent.atomic.LongAdder;

public class DbActionConfig {

    public static LongAdder writeNum = new LongAdder();

    public static boolean readonly = false;
    public static boolean debug = false;
    public static long writeMaxNum = -1;

    public static DbActionConfig build() {
        return new DbActionConfig();
    }

    public DbActionConfig setDbType(DbType dbType) {
        DialectHelper.setDbType(dbType);
        return this;
    }

    public DbActionConfig setReadonly(boolean readonly) {
        DbActionConfig.readonly = readonly;
        return this;
    }

    public DbActionConfig setDebug(boolean debug) {
        DbActionConfig.debug = debug;
        return this;
    }

    public DbActionConfig setWriteMaxNum(long writeMaxNum) {
        DbActionConfig.writeMaxNum = writeMaxNum;
        return this;
    }

    public DbActionConfig resetWriteNum() {
        writeNum.reset();
        return this;
    }

}
